#include <glib.h>

static void test_glib_spawning_proc_async(void)
{
    GPtrArray *argv = NULL;
    GPid child_pid = 0;
    GError *error = NULL;

    argv = g_ptr_array_new ();
    g_ptr_array_add (argv, (gpointer)"/bin/ls");
    g_ptr_array_add (argv, (gpointer)"-a");
    g_ptr_array_add (argv, (gpointer)"-l");
    g_ptr_array_add (argv, (gpointer)".");
    g_ptr_array_add (argv, (gpointer)"not_exist_file");
    g_ptr_array_add (argv, NULL);

    g_spawn_async(NULL, (char**)argv->pdata, NULL, G_SPAWN_DEFAULT, NULL, NULL, &child_pid, &error);

    g_usleep (1*1000*1000);

    g_assert_no_error (error);

    g_spawn_close_pid(child_pid);

    g_ptr_array_free (argv, TRUE);

    return;
}

gint main(gint argc, gchar **argv) 
{
    test_glib_spawning_proc_async();

    return 0;
}
